Skip to content

fix(fts): write a new term's df as a UINT64 value - #141

Open
zahariash wants to merge 1 commit into
LadybugDB:mainfrom
zahariash:fix/fts-df-uint64
Open

zahariash wants to merge 1 commit into
LadybugDB:mainfrom
zahariash:fix/fts-df-uint64

Conversation

@zahariash

@zahariash zahariash commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This work was produced with the help of language models.

FTSIndex::insertToTermsTable set a new term's df with dfVector.setValue(0, 1). The literal deduces int, so 4 bytes went into the UINT64 slot and the upper half kept what the vector held before. That half was zero in practice, so stored dfs were right.

LadybugDB/ladybug#1464 makes ValueVector::setValue<T> assert that T has the vector's value size. In runtime-check builds, which ladybug's CI uses (RUNTIME_CHECKS=1), this call then throws on every FTS insert or update that adds a new term. The df is now written as uint64_t. The change needs no engine change and has to merge before LadybugDB/ladybug#1464, which depends on it.

Tests. No new test: nothing can observe the 4-byte write without that assertion, and the existing fts tests cover the call once it is in. Under the assertion, the fts e2e run on main fails 11 tests, and the half-applied inserts then crash QUERY_FTS_INDEX in insertion.test's DeleteAndReCopy, a separate exception-safety problem. With this change the assertion never fires and 86 of the 87 tests pass. show_loaded_extensions also loads the duckdb extension, which the run did not build.

The df vector holds UINT64 values, but setValue(0, 1) deduces int and
writes 4 bytes into the 8-byte slot, leaving the upper half as it was.
It was zero in practice, so the stored df was right, but an engine
check that setValue writes the vector's value size rejects the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant